import 'package:flutter/material.dart';

class NavUser extends StatelessWidget {
  final Map<String, String> user;

  const NavUser({
    Key? key,
    required this.user,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 16.0),
      child: Row(
        children: [
          CircleAvatar(
            radius: 16,
            backgroundImage: user['avatar'] != null
                ? AssetImage(user['avatar']!)
                : null,
            child: user['avatar'] == null
                ? Text(
              user['name']?.substring(0, 1).toUpperCase() ?? 'U',
              style: const TextStyle(fontWeight: FontWeight.bold),
            )
                : null,
          ),
          const SizedBox(width: 8),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  user['name'] ?? 'User',
                  style: const TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 14,
                  ),
                ),
                Text(
                  user['email'] ?? '',
                  style: const TextStyle(
                    fontSize: 12,
                    color: Colors.grey,
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

